package controller;

import POJO.AppInfo;
import POJO.AppVersion;
import POJO.BackendUser;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import service.AppInfoService;
import service.AppVersionService;
import service.BackendUserService;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * Created by 任 on 2019/1/15.
 */
@Controller
@RequestMapping("/backendUser")
public class BackendUserController {
    @Resource
    private AppInfoService appInfoService;
    @Resource
    private BackendUserService backendUserService;
    @Resource
    private AppVersionService appVersionService;


    @RequestMapping("/login")
    public String login(){
        return "login";
    }

    @RequestMapping("/indexss")
    public String page(@RequestParam("userName") String userName,
                       @RequestParam("userPassword") String userPassword,
                       HttpSession session){
        BackendUser backendUser=backendUserService.LoginBackendUser(userName,userPassword);
        if(backendUser!=null){
            session.setAttribute("backendUser",backendUser);
            return "indexss";
        }else{
            
            return "login";
        }

    }
    //审核AppShowAppVersionAppInfo
    @RequestMapping("/ShowAppVersionAppInfo")
    public String ShowAppVersionAppInfo(Integer appId,Model model){
        AppInfo appInfo=appInfoService.appInfoListId(appId);
        model.addAttribute("appInfo",appInfo);
        AppVersion appVersion=appVersionService.AppVersionID(appId);
        model.addAttribute("appVersion",appVersion);
        model.addAttribute("ShowAppVersionAppInfo","ShowAppVersionAppInfo");

        return "indexss ";
    }
    @RequestMapping("/UpdateAppInfostatus")
    @ResponseBody
    public int UpdateAppInfostatus(Integer appId,Integer status){
        int update=appInfoService.UpdateAppInfostatus(appId,status);
        return update;
    }
}

